package org.nf.api;

import org.nf.material.model.Material;
import org.nf.material.service.MaterialService;
import org.nf.material.service.impl.MaterialServiceImpl;
import org.nf.partner.model.Partner;
import org.nf.partner.service.impl.PartnerServiceImpl;
import org.nf.product.vo.PageVO;
import org.nf.web.annotation.Model;
import org.nf.web.annotation.RequestMapping;
import org.nf.web.annotation.RequestParam;
import org.nf.web.servlet.View;
import org.nf.web.servlet.view.JsonView;

import javax.servlet.http.HttpSession;
import java.util.List;

public class MaterialController extends BaseController{
    private MaterialService service = new MaterialServiceImpl();
    /**
     * 查询合作商
     */
    @RequestMapping("/listMaterial")
    public View listMaterial(@Model Material material, HttpSession session){
        List<Material> materials = service.listMaterial(material);
        session.setAttribute("material",materials);
        return new JsonView(success("111"));
    }
    /**
     *  通过名称查询合作商
     */
    @RequestMapping("/getMaterial")
    public  View getMaterial(@RequestParam("materialName")String materialName){
        List<Material> material = service.selectMaterialName(materialName);
        return new JsonView(success(material));
    }

    /**
     * 通过分页查询
     */
    @RequestMapping("/listMaterialPaging")
    public View lisMaterialPaging(@RequestParam("page")int page,@RequestParam("limit")int limit){
        PageVO<List<Material>> listPageVO=service.listMaterialPage(page,limit);
        return new JsonView(success(listPageVO));
    }

}
